#pragma once
#include "defines.h"
#include <string>
class Terrain
{
public:
	struct Vertex
	{
		Vertex()
			:x(0), y(0), z(0), u(0), v(0), nx(0), ny(0), nz(0)
		{}
		float x, y, z;
		float nx, ny, nz;
		float u, v;
	};
public:
	Terrain(int width, int height, LPSTR fileName, float scaleX, float scaleY, float scaleZ, LPTSTR textureFile);

	Terrain(void);
	bool Open(int width, int height, LPSTR fileName, float scaleX, float scaleY, float scaleZ, LPTSTR textureFile);
	int GetNumVertex() const;
	int GetNumFaces() const;
	LPTSTR GetTextureName() const;
	void* GetData() const{return m_Data;}
	void* GetIndex() const{return m_Index;}
	int GetNumIndex() const{return (m_X - 1) * (m_Z - 1) * 2 * 3;}
	float getY(float x, float z);

	virtual ~Terrain(void);

private:
	long m_X;
	long m_Z;
	float m_ScaleX;
	float m_ScaleY;
	float m_ScaleZ;
	LPTSTR m_TextureFile;

	Vertex* m_Data;
	WORD * m_Index;

};
